using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;
using Pay.TO;

namespace Pay.Service.AutoMapper {
	public class TransferMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public TransferMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<transfer_dto, Transfer>()
				.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
				.ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchant_id))
				.ForMember(dest => dest.BindId, src => src.MapFrom(c => c.bind_id))
				.ForMember(dest => dest.PayId, src => src.MapFrom(c => c.pay_id))
				.ForMember(dest => dest.OrderNo, src => src.MapFrom(c => c.order_no))
				.ForMember(dest => dest.TransferAmount, src => src.MapFrom(c => c.transfer_amount))
				.ForMember(dest => dest.Amount, src => src.MapFrom(c => c.amount))
				.ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
				.ForMember(dest => dest.SettleAmount, src => src.MapFrom(c => c.settle_amount))
				.ForMember(dest => dest.MerchantSettle, src => src.MapFrom(c => c.merchant_settle))
				.ForMember(dest => dest.PlatSettle, src => src.MapFrom(c => c.plat_settle))
				.ForMember(dest => dest.BankName, src => src.MapFrom(c => c.bank_name))
				.ForMember(dest => dest.AccountNo, src => src.MapFrom(c => c.account_no))
				.ForMember(dest => dest.AccountName, src => src.MapFrom(c => c.account_name))
				.ForMember(dest => dest.IdCard, src => src.MapFrom(c => c.id_card))
				.ForMember(dest => dest.BusiType, src => src.MapFrom(c => c.busi_type))
				.ForMember(dest => dest.ApplyTime, src => src.MapFrom(c => c.apply_time.ToUnix()));
			_cfg.CreateMap<Transfer, transfer_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
				.ForMember(dest => dest.bind_id, src => src.MapFrom(c => c.BindId))
				.ForMember(dest => dest.pay_id, src => src.MapFrom(c => c.PayId))
				.ForMember(dest => dest.order_no, src => src.MapFrom(c => c.OrderNo))
				.ForMember(dest => dest.transfer_amount, src => src.MapFrom(c => c.TransferAmount))
				.ForMember(dest => dest.amount, src => src.MapFrom(c => c.Amount))
				.ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
				.ForMember(dest => dest.settle_amount, src => src.MapFrom(c => c.SettleAmount))
				.ForMember(dest => dest.merchant_settle, src => src.MapFrom(c => c.MerchantSettle))
				.ForMember(dest => dest.plat_settle, src => src.MapFrom(c => c.PlatSettle))
				.ForMember(dest => dest.bank_name, src => src.MapFrom(c => c.BankName))
				.ForMember(dest => dest.account_no, src => src.MapFrom(c => c.AccountNo))
				.ForMember(dest => dest.account_name, src => src.MapFrom(c => c.AccountName))
				.ForMember(dest => dest.id_card, src => src.MapFrom(c => c.IdCard))
				.ForMember(dest => dest.busi_type, src => src.MapFrom(c => c.BusiType))
				.ForMember(dest => dest.apply_time, src => src.MapFrom(c => c.ApplyTime.ToDateTime()))
				.ForMember(dest => dest.pay_info, src => src.MapFrom(c => c.PayInfo));
			_cfg.CreateMap<PagedResult<Transfer>, PagedResult<transfer_dto>>();

		}
	}
}
